﻿using System;

using QuickDev.Caching;
using QuickDev.Model;
using QuickDev.Licensing.Web;

namespace QuickDev.Web.UI
{
    public partial class SiteMasterPage : LongingsunMasterPage
    {
        #region Member Variables

        private SiteSettings _siteSettings;

        #endregion

        #region Properties

        /// <summary>
        /// Gets the site settings.
        /// </summary>
        /// <value>The site settings.</value>
        public SiteSettings SiteSettings
        {
            get
            {
                if ( _siteSettings == null )
                {
                    _siteSettings = SiteSettingsCache.GetCachedModel();
                    if ( _siteSettings == null )
                    {
                        _siteSettings = new SiteSettings();
                    }
                }
                return _siteSettings;
            }
        }

        #endregion

        #region Page Events

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnInit( EventArgs e )
        {
            base.OnInit( e );
            //set some value in Session in order to avoid Invalid ViewState Error: 
            //http://csharpaspnet.blogspot.com/2008/02/how-i-deal-with-cross-site-request.html
            //i.e.: Gotta have something in session to be able to use SessionID
            //Session["Snipe"] = "x";
            //Page.ViewStateUserKey = Session.SessionID;
        }

        #endregion

    }
}
